package pers.cj.pdos.controller.other;

import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import pers.cj.pdos.cache.EhcacheUtil;
import pers.cj.pdos.controller.base.BaseController;

import pers.cj.pdos.controller.entity.ResponseEntity;
import pers.cj.pdos.entity.User;
import pers.cj.pdos.realm.CustomRealm;

@Controller
@RequestMapping("/clear")
public class ClearController extends BaseController {
    @Autowired
    private CustomRealm customRealm;

    @ResponseBody
    @RequestMapping("/clear")
    public ResponseEntity clear(){
        //情况shiro缓存和数据库缓存
        EhcacheUtil.getInstance().clearAll();
        customRealm.prepareTime((User) SecurityUtils.getSubject().getPrincipal());
        customRealm.clearCached();
        return ResponseEntity.success();
    }
}
